

/*--------------------------------------------------------------------*/
/* ce fichier illustre comment les petites allocations influencent la
/* consommation de mémoire virtuelle
/*------------ -------------------------------------------------------*/



/*--------------------------------------------------------------------*/
/*parametres: h=1,2,3,4,5,6,7,8
/*            2^n
/*--------------------------------------------------------------------*/
#include "DumperStatusProc.h"
#include <math.h>
#include <string.h>
       


int N=4096*4096;
int H=0;

int main(int argc,char** argv){

  if(argc >=2){
     H = atoi(argv[1]);
     if(H > 20){
     	printf("top grosse taille\n");
     	return 0;
     }
  }
  else{
     printf("Usage: ./prog [ordre de puissance de la taille des bloc: int]\n");
     return 0;
  }
  printf("---------\n");
  /*instancier le dumperStatus ici*/
  DumperStatusProc dp;
  
  int steps = N;
  
  for(int i=1;i<= H;i++){
    steps/=2;
  }
  
  
  size_t size=(size_t) pow(2,H);
  printf("steps : %d, size : %d\n",steps,size);
  assert(steps * size == N);
  /*ici la boucle des allocations*/
  for(int i=1;i<= steps;i++){
     malloc(size);
  }
  
  status_t st = dp.getStatus();
  dp.printMeasure();
  
  printf("---------\n");
  return 0;
}
